﻿namespace UnitFundProfitability
{
	using System.Windows;
	using System.Windows.Threading;
	using UnitFundProfitability.BusinessLogic;

	/// <summary>
	/// Interaction logic for App.xaml.
	/// </summary>
	public partial class App : Application
	{
		#region Methods
		/// <summary>
		/// Raises the <see cref="E:System.Windows.Application.Startup"/> event.
		/// </summary>
		/// <param name="e">A <see cref="T:System.Windows.StartupEventArgs"/> that contains the event data.</param>
		protected override void OnStartup(StartupEventArgs e)
		{
			base.OnStartup(e);
			Dispatcher.UnhandledException += Dispatcher_UnhandledException;
		}

		/// <summary>
		/// Handles the UnhandledException event of the Dispatcher control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.Windows.Threading.DispatcherUnhandledExceptionEventArgs"/> instance containing the event data.</param>
		private void Dispatcher_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
		{
			Log.WriteException(e.Exception);
		}
		#endregion
	}
}
